package com.kingstar.ceres.data.handler;

import com.kingstar.ceres.data.constant.FileImportConstants;

import java.util.List;


public interface ITaskLockHandler<T> {

    void resetTaskStatus(String taskId, List<String> fileIds,String opDate,String status);

    default void fastFail(String taskId, String fileId, String opDate, String errMsg){
        taskStatusChange(taskId,fileId,opDate, FileImportConstants.STATUS_DOING,FileImportConstants.STATUS_FAILED,errMsg);
    }

    default void partFail(String taskId,String fileId,String opDate,String errMsg){
        taskStatusChange(taskId,fileId,opDate,null,FileImportConstants.STATUS_ERROR_DOING,errMsg);
    }

    boolean taskSuccess(String taskId,String fileId,String opDate,String successStatus);

    boolean taskComplete(String taskId,String opDate);

    void taskStatusChange(String taskId, String fileId, String opDate,String oldStatus ,String newStatus, String errMsg);

    boolean checkTaskStatusAndTransToDoing(String opDate, String taskID, String fileId,String execType);

    T selectAndInsertTask(String opDate, String taskID, String fileId,String execType);

    T queryTaskResultByID(String taskId, String opDate, String fileId) ;

    T insertNewTaskRecords(String opDate, String taskID, String fileId,String execType);
}
